const std = @import("std");
const cz_std = @import("cz_std.zig");
const lexer = @import("lexer.zig");

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    defer _ = gpa.deinit();
    const allocator = gpa.allocator();

    // 读取simple.cz文件
    const source = try std.fs.cwd().readFileAlloc("../examples/simple.cz", allocator, 1024 * 1024);
    defer allocator.free(source);

    std.debug.print("源代码:\n{s}\n\n", .{source});

    // 词法分析
    const tokens = try lexer.tokenize(allocator, source);
    defer allocator.free(tokens);

    std.debug.print("词法分析结果:\n", .{});
    for (tokens, 0..) |token, i| {
        std.debug.print("[{d:2}] 类型: {s:20} 值: '{s}' 行:{d} 列:{d}\n", .{
            i, @tagName(token.type), token.lexeme, token.line, token.column
        });
    }
}